package edu.westga.movierec.XAMPPtests.reader;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import edu.westga.movierec.model.*;
/**
 * Test methods for {@link edu.westga.movierec.model.XamppDBConnector Accessor Methods}.
 * 
 * @author Jean Cook, CS 6242, Fall 2009
 *
 */
public class DatabaseAccessorTests {
	private XamppDBConnector theDatabase;
	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		this.theDatabase = new XamppDBConnector();
	}
	//***************getMovieIndex Tests********************
	@Test
	public void shouldReturn1WhenMovieIsScream(){
		assertEquals(this.theDatabase.getMovieIndex("Scream"),1);
	}
	@Test
	public void shouldReturn5WhenMovieIsGhostbusters(){
		assertEquals(this.theDatabase.getMovieIndex("Ghostbusters"),5);
	}
	@Test
	public void shouldReturn3WhenMovieIsTitanic(){
		assertEquals(this.theDatabase.getMovieIndex("Titanic"),3);
	}
	@Test
	public void shouldReturn0WhenMovieIsTerminator(){
		assertEquals(this.theDatabase.getMovieIndex("Terminator"),0);
	}
	//****************getMovieTitle Tests********************
	@Test
	public void shouldReturnScreamWhenIndexIs1(){
		assertEquals(this.theDatabase.getMovieTitle(1),"Scream");
	}
	@Test
	public void shouldReturnGhostbustersWhenIndexIs5(){
		assertEquals(this.theDatabase.getMovieTitle(5),"Ghostbusters");
	}
	@Test
	public void shouldReturnMovieNotFoundWhenIndexIs25(){
		assertEquals(this.theDatabase.getMovieTitle(25),"Movie not found");
	}
	//*****************getMovieRating Tests************
	//May cease to work when modifiers UserLiked and UserHated begin
	@Test
	public void shouldReturn20WhenInputisScreamOutputisSaw(){
		assertEquals(this.theDatabase.getMovieRating("Scream","Saw"),20);
	}
	@Test
	public void shouldReturn5WhenInputisSawOutputisTitanic(){
		assertEquals(this.theDatabase.getMovieRating("Saw","Titanic"),5);
	}
}
